package com.hwhy.systemmonitoring.controller;

import com.hwhy.systemmonitoring.entity.*;
import com.hwhy.systemmonitoring.service.IStatusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 运行状态监控
 *
 * @author lfl
 * @since 2020-04-24
 */
@Slf4j
@RestController
@RequestMapping("/condition")
public class StatusController {

    @Autowired(required = false)
    private IStatusService iStatusService;

    /**
     * 获取所有信息（主要包含CPU、内存、磁盘状态、机房状态监控）
     *
     * @return JSON格式数据
     */
    @RequestMapping(value = "/getAllMessages", method = RequestMethod.GET)
    public Map<String, Object> getAllMessages() {
        return iStatusService.getAllMessages();
    }

    /**
     * 获取所有监控使用率(cpu使用率，内存使用率，磁盘使用情况)
     *
     * @return JSON格式数据
     */
    @RequestMapping(value = "/getAllUsageRate", method = RequestMethod.GET)
    public Map<Object, Object> getAllUsageRate() {
        return iStatusService.getAllUsageRate();
    }

    /**
     * 获取服务器Sys信息
     *
     * @return
     */
    @RequestMapping(value = "/getSysMessages", method = RequestMethod.GET)
    public Sys getSysMessages() {
        return iStatusService.getSysMessages();
    }

    /**
     * 获取Cpu信息
     *
     * @return
     */
    @RequestMapping(value = "/getCpuMessages", method = RequestMethod.GET)
    public Cpu getCpuMessages() {
        return iStatusService.getCpuMessages();
    }

    /**
     * 获取内存Mem信息
     *
     * @return
     */
    @RequestMapping(value = "/getMemMessages", method = RequestMethod.GET)
    public Mem getMemMessages() {
        return iStatusService.getMemMessages();
    }

    /**
     * 获取JVM信息
     *
     * @return
     */
    @RequestMapping(value = "/getJvmMessages", method = RequestMethod.GET)
    public Jvm getJvmMessages() {
        return iStatusService.getJvmMessages();
    }

    /**
     * 获取磁盘SysFile信息
     *
     * @return
     */
    @RequestMapping(value = "/getSysFileMessages", method = RequestMethod.GET)
    public List<SysFile> getSysFileMessages() {
        return iStatusService.getSysFileMessages();
    }
}
